﻿using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Threading;
using BLL;
using DAL;
using Models;
using System.Data;
using System.Text;
using System.Xml;
using Gift.WebApp;


public partial class backstage_advertising_set : Page
{

    protected string customXmlPath = "/cn/xml/custom_advertising.xml";

    protected string goodsListXmlPath = "/cn/xml/goods_list.xml";

    protected string homeXmlPath = "/cn/xml/home.xml";

    protected string ipushXmlPath = "/cn/xml/ipush_set.xml";
    protected string pageXmlPath = "/cn/xml/page.xml";
    protected string promotionGoodsListXmlPath = "/cn/xml/promotion_goods_list.xml";
   

    // Methods
    private void AdvertisingBind()
    {
        try
        {
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.homeXmlPath));
            XmlNodeList childNodes = document.SelectSingleNode("home_ad/slides").ChildNodes;
            XmlElement element = (XmlElement)childNodes[0];
            this.imgHomeSlides1.Src = element.GetAttribute("src");
            this.imgHomeSlides1.Alt = element.GetAttribute("alt");
            this.txtHomeSlidesAlt1.Value = element.GetAttribute("alt");
            this.txtHomeSlidesLink1.Value = element.GetAttribute("url");
            XmlElement element2 = (XmlElement)childNodes[1];
            this.imgHomeSlides2.Src = element2.GetAttribute("src");
            this.imgHomeSlides2.Alt = element2.GetAttribute("alt");
            this.txtHomeSlidesAlt2.Value = element2.GetAttribute("alt");
            this.txtHomeSlidesLink2.Value = element2.GetAttribute("url");
            XmlElement element3 = (XmlElement)childNodes[2];
            this.imgHomeSlides3.Src = element3.GetAttribute("src");
            this.imgHomeSlides3.Alt = element3.GetAttribute("alt");
            this.txtHomeSlidesAlt3.Value = element3.GetAttribute("alt");
            this.txtHomeSlidesLink3.Value = element3.GetAttribute("url");
            XmlElement element4 = (XmlElement)childNodes[3];
            this.imgHomeSlides4.Src = element4.GetAttribute("src");
            this.imgHomeSlides4.Alt = element4.GetAttribute("alt");
            this.txtHomeSlidesAlt4.Value = element4.GetAttribute("alt");
            this.txtHomeSlidesLink4.Value = element4.GetAttribute("url");
            XmlElement element5 = (XmlElement)childNodes[4];
            this.imgHomeSlides5.Src = element5.GetAttribute("src");
            this.imgHomeSlides5.Alt = element5.GetAttribute("alt");
            this.txtHomeSlidesAlt5.Value = element5.GetAttribute("alt");
            this.txtHomeSlidesLink5.Value = element5.GetAttribute("url");
            XmlElement element6 = (XmlElement)document.SelectSingleNode("home_ad/slides_bottom");
            this.imgHomeSlidesFoot.Src = element6.GetAttribute("src");
            this.imgHomeSlidesFoot.Alt = element6.GetAttribute("alt");
            this.txtHomeSlidesFootAlt.Value = element6.GetAttribute("alt");
            this.txtHomeSlidesFootLink.Value = element6.GetAttribute("url");
            XmlNodeList list2 = document.SelectSingleNode("home_ad/slides_right").ChildNodes;
            XmlElement element7 = (XmlElement)list2[0];
            this.imgHomeSlidesRight1.Src = element7.GetAttribute("src");
            this.imgHomeSlidesRight1.Alt = element7.GetAttribute("alt");
            this.txtHomeSlidesRightAlt1.Value = element7.GetAttribute("alt");
            this.txtHomeSlidesRightLink1.Value = element7.GetAttribute("url");
            XmlElement element8 = (XmlElement)list2[1];
            this.imgHomeSlidesRight2.Src = element8.GetAttribute("src");
            this.imgHomeSlidesRight2.Alt = element8.GetAttribute("alt");
            this.txtHomeSlidesRightAlt2.Value = element8.GetAttribute("alt");
            this.txtHomeSlidesRightLink2.Value = element8.GetAttribute("url");
            XmlElement element9 = (XmlElement)list2[2];
            this.imgHomeSlidesRight3.Src = element9.GetAttribute("src");
            this.imgHomeSlidesRight3.Alt = element9.GetAttribute("alt");
            this.txtHomeSlidesRightAlt3.Value = element9.GetAttribute("alt");
            this.txtHomeSlidesRightLink3.Value = element9.GetAttribute("url");
            XmlElement element10 = (XmlElement)document.SelectSingleNode("home_ad/category_right").ChildNodes[0];
            this.imgHomeCategoryRight.Src = element10.GetAttribute("src");
            this.imgHomeCategoryRight.Alt = element10.GetAttribute("alt");
            this.txtHomeCategoryRightAlt.Value = element10.GetAttribute("alt");
            this.txtHomeCategoryRightLink.Value = element10.GetAttribute("url");
            XmlNodeList list4 = document.SelectSingleNode("home_ad/new/left").ChildNodes;
            XmlElement element11 = (XmlElement)list4[0];
            this.imgHomeNewLeft1.Src = element11.GetAttribute("src");
            this.imgHomeNewLeft1.Alt = element11.GetAttribute("alt");
            this.txtHomeNewLeftAlt1.Value = element11.GetAttribute("alt");
            this.txtHomeNewLeftLink1.Value = element11.GetAttribute("url");
            XmlElement element12 = (XmlElement)list4[1];
            this.imgHomeNewLeft2.Src = element12.GetAttribute("src");
            this.imgHomeNewLeft2.Alt = element12.GetAttribute("alt");
            this.txtHomeNewLeftAlt2.Value = element12.GetAttribute("alt");
            this.txtHomeNewLeftLink2.Value = element12.GetAttribute("url");
            XmlNodeList list5 = document.SelectSingleNode("home_ad/new/right").ChildNodes;
            XmlElement element13 = (XmlElement)list5[0];
            this.imgHomeNewRight1.Src = element13.GetAttribute("src");
            this.imgHomeNewRight1.Alt = element13.GetAttribute("alt");
            this.txtHomeNewRightAlt1.Value = element13.GetAttribute("alt");
            this.txtHomeNewRightLink1.Value = element13.GetAttribute("url");
            XmlElement element14 = (XmlElement)list5[1];
            this.imgHomeNewRight2.Src = element14.GetAttribute("src");
            this.imgHomeNewRight2.Alt = element14.GetAttribute("alt");
            this.txtHomeNewRightAlt2.Value = element14.GetAttribute("alt");
            this.txtHomeNewRightLink2.Value = element14.GetAttribute("url");
            XmlNodeList list6 = document.SelectSingleNode("home_ad/category_ad").ChildNodes;
            XmlElement element15 = (XmlElement)list6[0];
            this.imgHomeCategory1.Src = element15.GetAttribute("src");
            this.imgHomeCategory1.Alt = element15.GetAttribute("alt");
            this.txtHomeCategoryAlt1.Value = element15.GetAttribute("alt");
            this.txtHomeCategoryLink1.Value = element15.GetAttribute("url");
            XmlElement element16 = (XmlElement)list6[1];
            this.imgHomeCategory2.Src = element16.GetAttribute("src");
            this.imgHomeCategory2.Alt = element16.GetAttribute("alt");
            this.txtHomeCategoryAlt2.Value = element16.GetAttribute("alt");
            this.txtHomeCategoryLink2.Value = element16.GetAttribute("url");
            XmlElement element17 = (XmlElement)list6[2];
            this.imgHomeCategory3.Src = element17.GetAttribute("src");
            this.imgHomeCategory3.Alt = element17.GetAttribute("alt");
            this.txtHomeCategoryAlt3.Value = element17.GetAttribute("alt");
            this.txtHomeCategoryLink3.Value = element17.GetAttribute("url");
            XmlElement element18 = (XmlElement)list6[3];
            this.imgHomeCategory4.Src = element18.GetAttribute("src");
            this.imgHomeCategory4.Alt = element18.GetAttribute("alt");
            this.txtHomeCategoryAlt4.Value = element18.GetAttribute("alt");
            this.txtHomeCategoryLink4.Value = element18.GetAttribute("url");
            XmlElement element19 = (XmlElement)document.SelectSingleNode("home_ad/middle");
            this.imgHomeCategoryMiddle.Src = element19.GetAttribute("src");
            this.imgHomeCategoryMiddle.Alt = element19.GetAttribute("alt");
            this.txtHomeCategoryMiddleAlt.Value = element19.GetAttribute("alt");
            this.txtHomeCategoryMiddleLink.Value = element19.GetAttribute("url");
            XmlElement element20 = (XmlElement)document.SelectSingleNode("home_ad/ipush");
            if (element20.GetAttribute("enable") == "true")
            {
                this.Radio1.Checked = true;
            }
            else
            {
                this.Radio2.Checked = true;
            }
            XmlNodeList list7 = document.SelectSingleNode("home_ad/ipush").ChildNodes;
            XmlElement element21 = (XmlElement)list7[0];
            this.imgIpush1.Src = element21.GetAttribute("src");
            this.imgIpush1.Alt = element21.GetAttribute("alt");
            this.txtIpushAlt1.Value = element21.GetAttribute("alt");
            this.txtIpushLink1.Value = element21.GetAttribute("url");
            XmlElement element22 = (XmlElement)list7[1];
            this.imgIpush2.Src = element22.GetAttribute("src");
            this.imgIpush2.Alt = element22.GetAttribute("alt");
            this.txtIpushAlt2.Value = element22.GetAttribute("alt");
            this.txtIpushLink2.Value = element22.GetAttribute("url");
            XmlElement element23 = (XmlElement)list7[2];
            this.imgIpush3.Src = element23.GetAttribute("src");
            this.imgIpush3.Alt = element23.GetAttribute("alt");
            this.txtIpushAlt3.Value = element23.GetAttribute("alt");
            this.txtIpushLink3.Value = element23.GetAttribute("url");
            XmlElement element24 = (XmlElement)list7[3];
            this.imgIpush4.Src = element24.GetAttribute("src");
            this.imgIpush4.Alt = element24.GetAttribute("alt");
            this.txtIpushAlt4.Value = element24.GetAttribute("alt");
            this.txtIpushLink4.Value = element24.GetAttribute("url");
            document.Load(base.Server.MapPath(this.goodsListXmlPath));
            XmlNodeList list8 = document.SelectSingleNode("goods_list_ad/right").ChildNodes;
            XmlElement element25 = (XmlElement)list8[0];
            this.imgGoodsListRight1.Src = element25.GetAttribute("src");
            this.imgGoodsListRight1.Alt = element25.GetAttribute("alt");
            this.txtGoodsListRightAlt1.Value = element25.GetAttribute("alt");
            this.txtGoodsListRightLink1.Value = element25.GetAttribute("url");
            XmlElement element26 = (XmlElement)list8[1];
            this.imgGoodsListRight2.Src = element26.GetAttribute("src");
            this.imgGoodsListRight2.Alt = element26.GetAttribute("alt");
            this.txtGoodsListRightAlt2.Value = element26.GetAttribute("alt");
            this.txtGoodsListRightLink2.Value = element26.GetAttribute("url");
            XmlElement element27 = (XmlElement)list8[2];
            this.imgGoodsListRight3.Src = element27.GetAttribute("src");
            this.imgGoodsListRight3.Alt = element27.GetAttribute("alt");
            this.txtGoodsListRightAlt3.Value = element27.GetAttribute("alt");
            this.txtGoodsListRightLink3.Value = element27.GetAttribute("url");
            XmlElement element28 = (XmlElement)list8[3];
            this.imgGoodsListRight4.Src = element28.GetAttribute("src");
            this.imgGoodsListRight4.Alt = element28.GetAttribute("alt");
            this.txtGoodsListRightAlt4.Value = element28.GetAttribute("alt");
            this.txtGoodsListRightLink4.Value = element28.GetAttribute("url");
            document.Load(base.Server.MapPath(this.promotionGoodsListXmlPath));
            XmlNodeList list9 = document.SelectSingleNode("promotion_goods_list_ad/right").ChildNodes;
            XmlElement element29 = (XmlElement)list9[0];
            this.imgPromotionRight1.Src = element29.GetAttribute("src");
            this.imgPromotionRight1.Alt = element29.GetAttribute("alt");
            this.txtPromotionRightAlt1.Value = element29.GetAttribute("alt");
            this.txtPromotionRightLink1.Value = element29.GetAttribute("url");
            XmlElement element30 = (XmlElement)list9[1];
            this.imgPromotionRight2.Src = element30.GetAttribute("src");
            this.imgPromotionRight2.Alt = element30.GetAttribute("alt");
            this.txtPromotionRightAlt2.Value = element30.GetAttribute("alt");
            this.txtPromotionRightLink2.Value = element30.GetAttribute("url");
            XmlElement element31 = (XmlElement)list9[2];
            this.imgPromotionRight3.Src = element31.GetAttribute("src");
            this.imgPromotionRight3.Alt = element31.GetAttribute("alt");
            this.txtPromotionRightAlt3.Value = element31.GetAttribute("alt");
            this.txtPromotionRightLink3.Value = element31.GetAttribute("url");
            document.Load(base.Server.MapPath(this.pageXmlPath));
            XmlElement element32 = (XmlElement)document.SelectSingleNode("page_ad/top");
            this.imgPageTop.Src = element32.GetAttribute("src");
            this.imgPageTop.Alt = element32.GetAttribute("alt");
            this.txtPageTopAlt.Value = element32.GetAttribute("alt");
            this.txtPageTopLink.Value = element32.GetAttribute("url");
            XmlElement element33 = (XmlElement)document.SelectSingleNode("page_ad/bottom");
            this.imgPageBottom.Src = element33.GetAttribute("src");
            this.imgPageBottom.Alt = element33.GetAttribute("alt");
            this.txtPageBottomAlt.Value = element33.GetAttribute("alt");
            this.txtPageBottomLink.Value = element33.GetAttribute("url");
            XmlElement element34 = (XmlElement)document.SelectSingleNode("page_ad/bottom_freight");
            this.imgPageBottomFreight.Src = element34.GetAttribute("src");
            this.imgPageBottomFreight.Alt = element34.GetAttribute("alt");
            this.txtPageBottomFreightAlt.Value = element34.GetAttribute("alt");
            this.txtPageBottomFreightLink.Value = element34.GetAttribute("url");
        }
        catch
        {
        }
    }

    protected void btnAdvertisingSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            HttpFileCollection files = HttpContext.Current.Request.Files;
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.homeXmlPath));
            XmlNodeList childNodes = document.SelectSingleNode("home_ad/slides").ChildNodes;
            if (files[0].FileName != "")
            {
                files[0].SaveAs(base.Server.MapPath("/cn/advertising/HomeSlides1.jpg"));
            }
            XmlElement element = (XmlElement)childNodes[0];
            element.SetAttribute("src", "/cn/advertising/HomeSlides1.jpg");
            element.SetAttribute("alt", this.txtHomeSlidesAlt1.Value);
            element.SetAttribute("url", this.txtHomeSlidesLink1.Value);
            if (files[1].FileName != "")
            {
                files[1].SaveAs(base.Server.MapPath("/cn/advertising/HomeSlides2.jpg"));
            }
            XmlElement element2 = (XmlElement)childNodes[1];
            element2.SetAttribute("src", "/cn/advertising/HomeSlides2.jpg");
            element2.SetAttribute("alt", this.txtHomeSlidesAlt2.Value);
            element2.SetAttribute("url", this.txtHomeSlidesLink2.Value);
            if (files[2].FileName != "")
            {
                files[2].SaveAs(base.Server.MapPath("/cn/advertising/HomeSlides3.jpg"));
            }
            XmlElement element3 = (XmlElement)childNodes[2];
            element3.SetAttribute("src", "/cn/advertising/HomeSlides3.jpg");
            element3.SetAttribute("alt", this.txtHomeSlidesAlt3.Value);
            element3.SetAttribute("url", this.txtHomeSlidesLink3.Value);
            if (files[3].FileName != "")
            {
                files[3].SaveAs(base.Server.MapPath("/cn/advertising/HomeSlides4.jpg"));
            }
            XmlElement element4 = (XmlElement)childNodes[3];
            element4.SetAttribute("src", "/cn/advertising/HomeSlides4.jpg");
            element4.SetAttribute("alt", this.txtHomeSlidesAlt4.Value);
            element4.SetAttribute("url", this.txtHomeSlidesLink4.Value);
            if (files[4].FileName != "")
            {
                files[4].SaveAs(base.Server.MapPath("/cn/advertising/HomeSlides5.jpg"));
            }
            XmlElement element5 = (XmlElement)childNodes[4];
            element5.SetAttribute("src", "/cn/advertising/HomeSlides5.jpg");
            element5.SetAttribute("alt", this.txtHomeSlidesAlt5.Value);
            element5.SetAttribute("url", this.txtHomeSlidesLink5.Value);
            XmlElement element6 = (XmlElement)document.SelectSingleNode("home_ad/slides_bottom");
            if (files[5].FileName != "")
            {
                files[5].SaveAs(base.Server.MapPath("/cn/advertising/HomeSlidesFoot.jpg"));
            }
            element6.SetAttribute("src", "/cn/advertising/HomeSlidesFoot.jpg");
            element6.SetAttribute("alt", this.txtHomeSlidesFootAlt.Value);
            element6.SetAttribute("url", this.txtHomeSlidesFootLink.Value);
            XmlNodeList list2 = document.SelectSingleNode("home_ad/slides_right").ChildNodes;
            if (files[6].FileName != "")
            {
                files[6].SaveAs(base.Server.MapPath("/cn/advertising/HomeSlidesRight1.jpg"));
            }
            XmlElement element7 = (XmlElement)list2[0];
            element7.SetAttribute("src", "/cn/advertising/HomeSlidesRight1.jpg");
            element7.SetAttribute("alt", this.txtHomeSlidesRightAlt1.Value);
            element7.SetAttribute("url", this.txtHomeSlidesRightLink1.Value);
            if (files[7].FileName != "")
            {
                files[7].SaveAs(base.Server.MapPath("/cn/advertising/HomeSlidesRight2.jpg"));
            }
            XmlElement element8 = (XmlElement)list2[1];
            element8.SetAttribute("src", "/cn/advertising/HomeSlidesRight2.jpg");
            element8.SetAttribute("alt", this.txtHomeSlidesRightAlt2.Value);
            element8.SetAttribute("url", this.txtHomeSlidesRightLink2.Value);
            if (files[8].FileName != "")
            {
                files[8].SaveAs(base.Server.MapPath("/cn/advertising/HomeSlidesRight3.jpg"));
            }
            XmlElement element9 = (XmlElement)list2[2];
            element9.SetAttribute("src", "/cn/advertising/HomeSlidesRight3.jpg");
            element9.SetAttribute("alt", this.txtHomeSlidesRightAlt3.Value);
            element9.SetAttribute("url", this.txtHomeSlidesRightLink3.Value);
            XmlNodeList list3 = document.SelectSingleNode("home_ad/category_right").ChildNodes;
            if (files[9].FileName != "")
            {
                files[9].SaveAs(base.Server.MapPath("/cn/advertising/HomeCategoryRight.jpg"));
            }
            XmlElement element10 = (XmlElement)list3[0];
            element10.SetAttribute("src", "/cn/advertising/HomeCategoryRight.jpg");
            element10.SetAttribute("alt", this.txtHomeCategoryRightAlt.Value);
            element10.SetAttribute("url", this.txtHomeCategoryRightLink.Value);
            XmlNodeList list4 = document.SelectSingleNode("home_ad/new/left").ChildNodes;
            if (files[10].FileName != "")
            {
                files[10].SaveAs(base.Server.MapPath("/cn/advertising/HomeNewLeft1.jpg"));
            }
            XmlElement element11 = (XmlElement)list4[0];
            element11.SetAttribute("src", "/cn/advertising/HomeNewLeft1.jpg");
            element11.SetAttribute("alt", this.txtHomeNewLeftAlt1.Value);
            element11.SetAttribute("url", this.txtHomeNewLeftLink1.Value);
            if (files[11].FileName != "")
            {
                files[11].SaveAs(base.Server.MapPath("/cn/advertising/HomeNewLeft2.jpg"));
            }
            XmlElement element12 = (XmlElement)list4[1];
            element12.SetAttribute("src", "/cn/advertising/HomeNewLeft2.jpg");
            element12.SetAttribute("alt", this.txtHomeNewLeftAlt2.Value);
            element12.SetAttribute("url", this.txtHomeNewLeftLink2.Value);
            XmlNodeList list5 = document.SelectSingleNode("home_ad/new/right").ChildNodes;
            if (files[12].FileName != "")
            {
                files[12].SaveAs(base.Server.MapPath("/cn/advertising/HomeNewRight1.jpg"));
            }
            XmlElement element13 = (XmlElement)list5[0];
            element13.SetAttribute("src", "/cn/advertising/HomeNewRight1.jpg");
            element13.SetAttribute("alt", this.txtHomeNewRightAlt1.Value);
            element13.SetAttribute("url", this.txtHomeNewRightLink1.Value);
            if (files[13].FileName != "")
            {
                files[13].SaveAs(base.Server.MapPath("/cn/advertising/HomeNewRight2.jpg"));
            }
            XmlElement element14 = (XmlElement)list5[1];
            element14.SetAttribute("src", "/cn/advertising/HomeNewRight2.jpg");
            element14.SetAttribute("alt", this.txtHomeNewRightAlt2.Value);
            element14.SetAttribute("url", this.txtHomeNewRightLink2.Value);
            XmlNodeList list6 = document.SelectSingleNode("home_ad/category_ad").ChildNodes;
            if (files[14].FileName != "")
            {
                files[14].SaveAs(base.Server.MapPath("/cn/advertising/HomeCategory1.jpg"));
            }
            XmlElement element15 = (XmlElement)list6[0];
            element15.SetAttribute("src", "/cn/advertising/HomeCategory1.jpg");
            element15.SetAttribute("alt", this.txtHomeCategoryAlt1.Value);
            element15.SetAttribute("url", this.txtHomeCategoryLink1.Value);
            if (files[15].FileName != "")
            {
                files[15].SaveAs(base.Server.MapPath("/cn/advertising/HomeCategory2.jpg"));
            }
            XmlElement element16 = (XmlElement)list6[1];
            element16.SetAttribute("src", "/cn/advertising/HomeCategory2.jpg");
            element16.SetAttribute("alt", this.txtHomeCategoryAlt2.Value);
            element16.SetAttribute("url", this.txtHomeCategoryLink2.Value);
            if (files[0x10].FileName != "")
            {
                files[0x10].SaveAs(base.Server.MapPath("/cn/advertising/HomeCategory3.jpg"));
            }
            XmlElement element17 = (XmlElement)list6[2];
            element17.SetAttribute("src", "/cn/advertising/HomeCategory3.jpg");
            element17.SetAttribute("alt", this.txtHomeCategoryAlt3.Value);
            element17.SetAttribute("url", this.txtHomeCategoryLink3.Value);
            if (files[0x11].FileName != "")
            {
                files[0x11].SaveAs(base.Server.MapPath("/cn/advertising/HomeCategory4.jpg"));
            }
            XmlElement element18 = (XmlElement)list6[3];
            element18.SetAttribute("src", "/cn/advertising/HomeCategory4.jpg");
            element18.SetAttribute("alt", this.txtHomeCategoryAlt4.Value);
            element18.SetAttribute("url", this.txtHomeCategoryLink4.Value);
            XmlElement element19 = (XmlElement)document.SelectSingleNode("home_ad/middle");
            if (files[0x12].FileName != "")
            {
                files[0x12].SaveAs(base.Server.MapPath("/cn/advertising/HomeCategoryMiddle.jpg"));
            }
            element19.SetAttribute("src", "/cn/advertising/HomeCategoryMiddle.jpg");
            element19.SetAttribute("alt", this.txtHomeCategoryMiddleAlt.Value);
            element19.SetAttribute("url", this.txtHomeCategoryMiddleLink.Value);
            XmlElement element20 = (XmlElement)document.SelectSingleNode("home_ad/ipush");
            if (this.Radio1.Checked)
            {
                element20.SetAttribute("enable", "true");
            }
            else if (this.Radio2.Checked)
            {
                element20.SetAttribute("enable", "false");
            }
            document.Save(base.Server.MapPath(this.homeXmlPath));
            document.Load(base.Server.MapPath(this.ipushXmlPath));
            XmlNodeList list7 = document.SelectSingleNode("set").ChildNodes;
            ArrayList list8 = ArrayList.Adapter(base.Request.Form["ipushAd"].Split(new char[] { ',' }));
            ArrayList list9 = ArrayList.Adapter(base.Request.Form["ipushAdTitle"].Split(new char[] { ',' }));
            for (int i = 0; i < list7.Count; i++)
            {
                XmlElement element21 = list7[i] as XmlElement;
                element21.SetAttribute("chance",  list8[i].ToString());
                element21.SetAttribute("ad_title", list9[i].ToString());
            }
            document.Save(base.Server.MapPath(this.ipushXmlPath));
            document.Load(base.Server.MapPath(this.homeXmlPath));
            XmlNodeList list10 = document.SelectSingleNode("home_ad/ipush").ChildNodes;
            if (files[0x13].FileName != "")
            {
                files[0x13].SaveAs(base.Server.MapPath("/cn/advertising/ipush1.jpg"));
            }
            XmlElement element22 = (XmlElement)list10[0];
            element22.SetAttribute("src", "/cn/advertising/ipush1.jpg");
            element22.SetAttribute("alt", this.txtIpushAlt1.Value);
            element22.SetAttribute("url", this.txtIpushLink1.Value);
            if (files[20].FileName != "")
            {
                files[20].SaveAs(base.Server.MapPath("/cn/advertising/ipush2.jpg"));
            }
            XmlElement element23 = (XmlElement)list10[1];
            element23.SetAttribute("src", "/cn/advertising/ipush2.jpg");
            element23.SetAttribute("alt", this.txtIpushAlt2.Value);
            element23.SetAttribute("url", this.txtIpushLink2.Value);
            if (files[0x15].FileName != "")
            {
                files[0x15].SaveAs(base.Server.MapPath("/cn/advertising/ipush3.jpg"));
            }
            XmlElement element24 = (XmlElement)list10[2];
            element24.SetAttribute("src", "/cn/advertising/ipush3.jpg");
            element24.SetAttribute("alt", this.txtIpushAlt3.Value);
            element24.SetAttribute("url", this.txtIpushLink3.Value);
            if (files[0x16].FileName != "")
            {
                files[0x16].SaveAs(base.Server.MapPath("/cn/advertising/ipush4.jpg"));
            }
            XmlElement element25 = (XmlElement)list10[3];
            element25.SetAttribute("src", "/cn/advertising/ipush4.jpg");
            element25.SetAttribute("alt", this.txtIpushAlt4.Value);
            element25.SetAttribute("url", this.txtIpushLink4.Value);
            document.Save(base.Server.MapPath(this.homeXmlPath));
            document.Load(base.Server.MapPath(this.goodsListXmlPath));
            XmlNodeList list11 = document.SelectSingleNode("goods_list_ad/right").ChildNodes;
            if (files[0x17].FileName != "")
            {
                files[0x17].SaveAs(base.Server.MapPath("/cn/advertising/GoodsListRight1.jpg"));
            }
            XmlElement element26 = (XmlElement)list11[0];
            element26.SetAttribute("src", "/cn/advertising/GoodsListRight1.jpg");
            element26.SetAttribute("alt", this.txtGoodsListRightAlt1.Value);
            element26.SetAttribute("url", this.txtGoodsListRightLink1.Value);
            if (files[0x18].FileName != "")
            {
                files[0x18].SaveAs(base.Server.MapPath("/cn/advertising/GoodsListRight2.jpg"));
            }
            XmlElement element27 = (XmlElement)list11[1];
            element27.SetAttribute("src", "/cn/advertising/GoodsListRight2.jpg");
            element27.SetAttribute("alt", this.txtGoodsListRightAlt2.Value);
            element27.SetAttribute("url", this.txtGoodsListRightLink2.Value);
            if (files[0x19].FileName != "")
            {
                files[0x19].SaveAs(base.Server.MapPath("/cn/advertising/GoodsListRight3.jpg"));
            }
            XmlElement element28 = (XmlElement)list11[2];
            element28.SetAttribute("src", "/cn/advertising/GoodsListRight3.jpg");
            element28.SetAttribute("alt", this.txtGoodsListRightAlt3.Value);
            element28.SetAttribute("url", this.txtGoodsListRightLink3.Value);
            if (files[0x1a].FileName != "")
            {
                files[0x1a].SaveAs(base.Server.MapPath("/cn/advertising/GoodsListRight4.jpg"));
            }
            XmlElement element29 = (XmlElement)list11[3];
            element29.SetAttribute("src", "/cn/advertising/GoodsListRight4.jpg");
            element29.SetAttribute("alt", this.txtGoodsListRightAlt4.Value);
            element29.SetAttribute("url", this.txtGoodsListRightLink4.Value);
            document.Save(base.Server.MapPath(this.goodsListXmlPath));
            document.Load(base.Server.MapPath(this.promotionGoodsListXmlPath));
            XmlNodeList list12 = document.SelectSingleNode("promotion_goods_list_ad/right").ChildNodes;
            XmlElement element30 = (XmlElement)list12[0];
            if (files[0x1b].FileName != "")
            {
                files[0x1b].SaveAs(base.Server.MapPath("/cn/advertising/PromotionGoodsListRight1.jpg"));
            }
            element30.SetAttribute("src", "/cn/advertising/PromotionGoodsListRight1.jpg");
            element30.SetAttribute("alt", this.txtPromotionRightAlt1.Value);
            element30.SetAttribute("url", this.txtPromotionRightLink1.Value);
            XmlElement element31 = (XmlElement)list12[1];
            if (files[0x1c].FileName != "")
            {
                files[0x1c].SaveAs(base.Server.MapPath("/cn/advertising/PromotionGoodsListRight2.jpg"));
            }
            element31.SetAttribute("src", "/cn/advertising/PromotionGoodsListRight2.jpg");
            element31.SetAttribute("alt", this.txtPromotionRightAlt2.Value);
            element31.SetAttribute("url", this.txtPromotionRightLink2.Value);
            XmlElement element32 = (XmlElement)list12[2];
            if (files[0x1d].FileName != "")
            {
                files[0x1d].SaveAs(base.Server.MapPath("/cn/advertising/PromotionGoodsListRight3.jpg"));
            }
            element32.SetAttribute("src", "/cn/advertising/PromotionGoodsListRight3.jpg");
            element32.SetAttribute("alt", this.txtPromotionRightAlt3.Value);
            element32.SetAttribute("url", this.txtPromotionRightLink3.Value);
            document.Save(base.Server.MapPath(this.promotionGoodsListXmlPath));
            document.Load(base.Server.MapPath(this.pageXmlPath));
            XmlElement element33 = (XmlElement)document.SelectSingleNode("page_ad/top");
            if (files[30].FileName != "")
            {
                files[30].SaveAs(base.Server.MapPath("/cn/advertising/PageTop.jpg"));
            }
            element33.SetAttribute("src", "/cn/advertising/PageTop.jpg");
            element33.SetAttribute("alt", this.txtPageTopAlt.Value);
            element33.SetAttribute("url", this.txtPageTopLink.Value);
            XmlElement element34 = (XmlElement)document.SelectSingleNode("page_ad/bottom");
            if (files[0x1f].FileName != "")
            {
                files[0x1f].SaveAs(base.Server.MapPath("/cn/advertising/PageBottom.jpg"));
            }
            element34.SetAttribute("src", "/cn/advertising/PageBottom.jpg");
            element34.SetAttribute("alt", this.txtPageBottomAlt.Value);
            element34.SetAttribute("url", this.txtPageBottomLink.Value);
            XmlElement element35 = (XmlElement)document.SelectSingleNode("page_ad/bottom_freight");
            if (files[0x20].FileName != "")
            {
                files[0x20].SaveAs(base.Server.MapPath("/cn/advertising/PageBottomFreight.jpg"));
            }
            element35.SetAttribute("src", "/cn/advertising/PageBottomFreight.jpg");
            element35.SetAttribute("alt", this.txtPageBottomFreightAlt.Value);
            element35.SetAttribute("url", this.txtPageBottomFreightLink.Value);
            document.Save(base.Server.MapPath(this.pageXmlPath));
            document.Load(base.Server.MapPath(this.customXmlPath));
            XmlElement element36 = (XmlElement)document.SelectSingleNode("custom_ad");
            if (files.Count > 0x21)
            {
                Array array = base.Request.Form["hdCustomAd"].Split(new char[] { ',' });
                Array array2 = base.Request.Form["customAdAlt"].Split(new char[] { ',' });
                Array array3 = base.Request.Form["customAdUrl"].Split(new char[] { ',' });
                element36.RemoveAll();
                for (int j = 0x21; j < files.Count; j++)
                {
                    int index = j - 0x21;
                    string path = "";
                    if (files[j].FileName != "")
                    {
                        path = "/cn/advertising/" + DateTime.Now.ToString("yyyyMMddHHmmssffffff") + ".jpg";
                        files[j].SaveAs(base.Server.MapPath(path));
                        if (array.GetValue(index).ToString() != "0")
                        {
                            File.Delete(base.Server.MapPath(array.GetValue(index).ToString()));
                        }
                    }
                    else
                    {
                        path = array.GetValue(index).ToString();
                    }
                    XmlElement newChild = document.CreateElement("ad");
                    newChild.SetAttribute("src", path);
                    newChild.SetAttribute("alt", array2.GetValue(index).ToString());
                    newChild.SetAttribute("url", array3.GetValue(index).ToString());
                    element36.AppendChild(newChild);
                    Thread.Sleep(100);
                }
            }
            else
            {
                element36.RemoveAll();
            }
            document.Save(base.Server.MapPath(this.customXmlPath));
            base.ClientScript.RegisterStartupScript(base.GetType(), "message", "<script language=\"javascript\" defer>alert(\"更新成功！\");location.href=\"advertising_set.aspx\";</script>");
        }
        catch
        {
        }
    }

    protected StringBuilder CustomAdBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.customXmlPath));
            XmlNodeList childNodes = document.SelectSingleNode("custom_ad").ChildNodes;
            for (int i = 0; i < childNodes.Count; i++)
            {
                XmlElement element = (XmlElement)childNodes[i];
                builder.AppendLine("<tr>");
                builder.AppendLine("<td>自定义广告</td>");
                builder.AppendLine("<td><img id=\"img1\" src=\"" + element.GetAttribute("src") + "\" style=\"width: 380px;\" alt=\"" + element.GetAttribute("alt") + "\" /></td>");
                builder.AppendLine("<td>");
                builder.AppendLine("图片地址：" + element.GetAttribute("src") + "<br /><br />");
                builder.AppendLine("图片路径：<input name=\"fileCustomAd\" type=\"file\" class=\"file\" /><br /><br />");
                builder.AppendLine("<span class=\"imgClass\">图片分辨率：72像素 格式：jpg,bmp,gif,png</span><br /><br />");
                builder.AppendLine("图片描述：<input name=\"customAdAlt\" type=\"text\" class=\"file\" maxlength=\"50\" value=\"" + element.GetAttribute("alt") + "\" /><br /><br />");
                builder.AppendLine("链接地址：<input name=\"customAdUrl\" type=\"text\" class=\"file\" maxlength=\"200\" value=\"" + element.GetAttribute("url") + "\" /><input name=\"hdCustomAd\" type=\"hidden\" value=\"" + element.GetAttribute("src") + "\" />");
                builder.AppendLine("</td>");
                builder.AppendLine("<td><input id=\"Button1\" type=\"button\" class=\"formButton\" value=\"删除广告\" title=\"删除广告\" onclick=\"DelCustomAd(this.parentNode.parentNode.rowIndex);\" /></td>");
                builder.AppendLine("</tr>");
            }
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder IpushSetBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.ipushXmlPath));
            XmlNodeList childNodes = document.SelectSingleNode("set").ChildNodes;
            builder.AppendLine("<table>");
            for (int i = 0; i < childNodes.Count; i++)
            {
                XmlElement element = childNodes[i] as XmlElement;
                builder.AppendLine("<tr>");
                builder.AppendLine("<td>" + element.GetAttribute("title") + "：</td><td><input name=\"ipushAd\" type=\"text\" maxlength=\"3\" value=\"" + element.GetAttribute("chance") + "\" onpaste=\"return false\" style=\"ime-mode: disabled\" onkeypress=\"if ((event.keyCode<48 || event.keyCode>57||event.keyCode==46)) event.returnValue=false\" /> *弹出机率(单位：百分比)</td><td>标题：</td><td><input name=\"ipushAdTitle\" type=\"text\" value=\"" + element.GetAttribute("ad_title") + "\" /></td><td>预览图：</td><td><img style=\"border: 1px solid #cfcfcf;\" src=\"/cn/advertising/" + element.GetAttribute("title") + ".jpg\"/></td>");
                builder.AppendLine("</tr>");
            }
            builder.AppendLine("</table>");
        }
        catch
        {
        }
        return builder;
    }

    protected override object LoadPageStateFromPersistenceMedium()
    {
        byte[] inArray = ViewStateCompression.DeCompress(Convert.FromBase64String(base.Request.Form.Get("__MSPVSTATE")));
        LosFormatter formatter = new LosFormatter();
        return formatter.Deserialize(Convert.ToBase64String(inArray));
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if ((HttpContext.Current.Session["admin_user"] == null) && (HttpContext.Current.Session["language_version"] == null))
        {
            base.ClientScript.RegisterStartupScript(base.GetType(), "sJs", "top.location=\"login.html\";", true);
        }
        if (!base.IsPostBack)
        {
            this.AdvertisingBind();
        }
    }

    protected override void SavePageStateToPersistenceMedium(object pViewState)
    {
        LosFormatter formatter = new LosFormatter();
        StringWriter output = new StringWriter();
        formatter.Serialize(output, pViewState);
        string hiddenFieldInitialValue = Convert.ToBase64String(ViewStateCompression.Compress(Convert.FromBase64String(output.ToString())));
        base.ClientScript.RegisterHiddenField("__MSPVSTATE", hiddenFieldInitialValue);
    }
}


